import React, { Component } from 'react'
import PropTypes from 'prop-types'

import './css/navbar.css'

export default class Navbar extends Component {
  static defaultProps = {
    title: '',
    leftTitle: '返回',
    rightTitle: '',
    leftClick: () => {},
    rightClick: () => {},
  }

  static propTypes = {
    title: PropTypes.string,
    leftTitle: PropTypes.string,
    rightTitle: PropTypes.string,
    leftClick: PropTypes.func,
    rightClick: PropTypes.func,
  }

  render() {
    return (
      <ul className='navbar'>
        <li>
          <button onClick={() => this.props.leftClick()}>
            {this.props.leftTitle}
          </button>
        </li>
        <li className='title'>{this.props.title}</li>
        <li>
          <button onClick={() => this.props.rightClick()}>
            {this.props.rightTitle}
          </button>
        </li>
      </ul>
    )
  }
}
